﻿using MediatR;
using SheepStorage.API.Application.Command.SheepChangeDormCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepChangeDormHandler
{
	public class ChangeDormShowHandler : IRequestHandler<ChangeDormShowCommand, Results<PageOutput<SheepChangeDormitoryOutput>>>
	{



		private readonly IChangeDormitoryService service;


		public ChangeDormShowHandler(IChangeDormitoryService service)
		{
			this.service = service;
		}



		/// <summary>
		/// 羊只转舍列表
		/// </summary>
		/// <param name="request"></param>
		/// <param name="cancellationToken"></param>
		/// <returns></returns>


		public async Task<Results<PageOutput<SheepChangeDormitoryOutput>>> Handle(ChangeDormShowCommand request, CancellationToken cancellationToken)
		{
			//throw new NotImplementedException();

	     	var result = await service.GetChangeDormitories(request.StartChangedormDate, request.EndChangedormDate, request.OverBit, request.ChangedormitoryType, request.TransferOutDormitory, request.RollOutField, request.TransferToDormitory, request.DriveField, request.Pageindex, request.Pagesize);

			return Results<PageOutput<SheepChangeDormitoryOutput>>.DataResult(result);

		}
	}
}
